//
//  CharacterUnitCollectionViewCell.m
//  us
//
//  Created by karry on 2025/4/1.
//

#import "CharacterUnitCollectionViewCell.h"

@implementation CharacterUnitCollectionViewCell

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initialization];
    }
    return self;
}

-(void)initialization{
    
    [self bgView];
    [self imgView];
}

- (void)setSelected:(BOOL)selected{
    [super setSelected:selected];
    
    if (selected) {
        self.bgView.layer.borderColor = [UIColor jk_colorWithHex:0x6FB5FF].CGColor;
        self.bgView.layer.borderWidth = 3;
    }else {
        self.bgView.layer.borderColor = UIColor.borderColor.CGColor;
        self.bgView.layer.borderWidth = 2;
    }
}

- (UIView *)bgView {
    if (_bgView == nil) {
        _bgView = [[UIView alloc]init];
        _bgView.layer.masksToBounds = YES;
        _bgView.layer.cornerRadius = 10;
        _bgView.layer.borderWidth = 2;
        _bgView.layer.borderColor = UIColor.borderColor.CGColor;
        [self.contentView addSubview:_bgView];
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
    }
    return  _bgView;
}
-(UIImageView *)imgView{
    if (!_imgView) {
        _imgView = [[UIImageView alloc]init];
         [self.bgView addSubview:_imgView];
          [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
              make.top.equalTo(self.bgView).offset(8);
              make.left.equalTo(self.bgView).offset(8);
              make.right.equalTo(self.bgView).offset(-8);
              make.bottom.equalTo(self.bgView).offset(-8);

        }];
    }
    return _imgView;
}
@end
